<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
  //setTimeout()
var n =0;

function repeat(func, num ,times ){
    var key = setInterval(function(){
        func('执行次数'+ ++n );
        if(n>= num){
            clearInterval(key);
        }
    }, times)
    // for(let i =0;i< num;i++){
    //     func('执行次数'+ ++n );
    // }
}

repeat( console.log, 6 , 3000);
  


</script>


</body>
</html>